<? if (!defined("BASEPATH")) exit("No direct script access allowed");

//Common::pr($getInsEnt2cat);
//Common::pr($more_ins);
echo	"<aside class=\"sidebar\">";

if(isset($getInsEnt2cat)) {
	if(isset($more_ins) and count($more_ins) > 1) {
		foreach($more_ins as $_ins_id => $_ins_data) {
			$options[$_ins_id] = $_ins_data["insName"];
		}
		
		echo	"
				<script type=\"text/javascript\">
					function jsShowBox(insId) {
						for(var i = 0; i < $('.insbox').length; i++) {
							console.info($($('.insbox')[i]));
							if($($('.insbox')[i]).attr('id') == 'insbox_' + insId) {
								$($('.insbox')[i]).show();
							} else {
								$($('.insbox')[i]).hide();
							}
						}
					}
				</script>
				";
		
		echo 	form_dropdown("ins_id", $options, NULL, "class=\"data w100\" style=\"margin-bottom:2px;\" onchange=\"jsShowBox(this.value);\"");
	}
	echo	"<div class=\"insbox\" id=\"insbox_".$insId."\" ".((isset($style))?("style=\"".$style."\""):("")).">";
	echo		"<div class=\"box gray sideinfo\">";
	echo			"<h3 class=\"boxtitle\">".$insName."</h3>";
	if(count($getInsEnt2cat)) {
		echo			"<div class=\"boxcontent\">";
		echo				"<dl>";
		foreach($getInsEnt2cat as $catData) {
			echo					"<dt>".$catData["catName"].":</dt><dd>".Common::coalesce(array($catData["e2cInt"], auto_link($catData["e2cText"], "both", TRUE)))."</dd>";
		}
		echo				"</dl>";
		echo			"</div>";
	}
	echo		"</div>";


	echo		"<div class=\"box green sideinfo\">";
	if(!$this->session->userdata("usrId")) {
		echo			"<h3>".$this->lang->line("QUESTIONS_LOG_IN_AND_CONTACT_THE_INSTITUTE")."</h3>";
	} else {
		echo			"<h3 class=\"boxtitle\">".$this->lang->line("QUESTIONS_CONTACT_THE_INSTITUTE")."</h3>";
		echo			"<div class=\"boxcontent\">";
		echo				$contactForm;
		echo			"</div>";
	}
	echo		"</div>";
	echo	"</div>";
}

if(isset($getArticleByEntId) and count($getArticleByEntId)) {
	echo		"<div class=\"box gray sideinfo\">";
	echo			"<h3 class=\"boxtitle\">".$this->lang->line("RELATED_ARTICLE").((count($getArticleByEntId) > 1)?("s"):(""))."</h3>";
	echo			"<div class=\"boxcontent\">";

	echo				"<ul>";
	foreach($getArticleByEntId as $art) {
		echo					"<li>".anchor($art->art_url_name, $art->art_name)."</li>";
	}
	echo				"</ul>";

	echo			"</div>";
	echo		"</div>";
}

if(isset($getTags) and isset($getTags["tags"]) and count($getTags["tags"])) {
	echo		"<div class=\"box gray sideinfo\">";
	echo			"<h3 class=\"boxtitle\">".$this->lang->line("TAG_CLOUD")."</h3>";
	echo			"<div class=\"boxcontent\">";

	$displayFontSize = 12;
	$maxFontSize = 20;
	foreach($getTags["tags"] as $tag) {
		$fontSize = (($tag["cnt"] > $getTags["minCnt"])?(ceil($displayFontSize+(($maxFontSize-$displayFontSize)*($tag["cnt"]/$getTags["maxCnt"])))):($displayFontSize));
		echo	anchor($tag["url"], $tag["name"], "style=\"font-size: ".$fontSize."px\"")." ";
	}

	echo			"</div>";
	echo		"</div>";
}


echo	"</aside>";